package com.storm.lib.bean;

import java.util.ArrayList;
import java.util.List;

import com.storm.lib.exception.InvalidParamException;
import com.storm.lib.util.ExceptionUtil;



/**
 *
 * 类功能:包含了规则，具体看Excel表达式(resource/表达式说明/Excel表达式.txt)
 * @author johnny
 * @version 2010-10-27
 */
public class DataColumnRuleBean {

	private String typePrefix;
	private Object nullValue;
	/**
	 * i,#类型==TINYINT:1,类型==BIGINT:20,#NOTNULL里的#NOTNULL
	 */
	private Boolean notNone=false;

	private List<ReplaceBean> replaceList;

	/**
	 *
	 * 更新时间:2010-10-28, 作者:johnny
	 * 方法功能:通过str增加ReplaceBean
	 * @param str 例如#类型==TINYINT:1
	 */
	public void addReplaceBeanByStr(String expressionStr){
		if(expressionStr==null || expressionStr.startsWith("#")==false){
			ExceptionUtil.throwException(new InvalidParamException());
		}
		expressionStr = expressionStr.replace("#", "");
		String[] exps = expressionStr.split("==");
		String leftExp = exps[0];
		String[] rightExps = exps[1].split(":");

		ReplaceBean replaceBean = new ReplaceBean();
		if(replaceList==null){
			replaceList = new ArrayList<ReplaceBean>();
		}
		replaceBean.setConditionColumnName(leftExp);
		replaceBean.setConditionValue(rightExps[0]);
		replaceBean.setReplaceValue(rightExps[1]);
		this.replaceList.add(replaceBean);
	}
	public String getTypePrefix() {
		return typePrefix;
	}
	public void setTypePrefix(String typePrefix) {
		this.typePrefix = typePrefix;
	}
	public Object getNullValue() {
		return nullValue;
	}
	public void setNullValue(Object nullValue) {
		this.nullValue = nullValue;
	}
	public List<ReplaceBean> getReplaceList() {
		return replaceList;
	}
	public void setReplaceList(List<ReplaceBean> replaceList) {
		this.replaceList = replaceList;
	}

	/**
	 * @return the notNone
	 */
	public Boolean getNotNone() {
		return notNone;
	}

	/**
	 * @param notNone the notNone to set
	 */
	public void setNotNone(Boolean notNone) {
		this.notNone = notNone;
	}

}
